package com.example.myapplication.HomeAdapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.myapplication.HomeBean.HomeXinWenBean;
import com.example.myapplication.R;

import java.util.ArrayList;
import java.util.List;

public class HomeXinWenAdapter extends BaseAdapter {
    List<HomeXinWenBean>list=new ArrayList<>();
    Activity activity;

    public HomeXinWenAdapter(List<HomeXinWenBean> list, Activity activity) {
        this.list = list;
        this.activity = activity;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view= LayoutInflater.from(activity).inflate(R.layout.home_xinwen_mokuai,null);
        TextView id=view.findViewById(R.id.Home_XinWen_id);
        TextView text=view.findViewById(R.id.Home_XinWen_text);
        id.setText(list.get(i).getId());
        text.setText(list.get(i).getText());
        id.setVisibility(View.INVISIBLE);
        return view;
    }
}
